
    function postcode_call(postcode){
      postcode = postcode.replace(/\D/g,"")
      url="http://cep.correiocontrol.com.br/"+postcode+".js"
      s=document.createElement('script')
      s.setAttribute('charset','utf-8')
      s.src=url
      document.querySelector('head').appendChild(s)
    }

    function correiocontrolcep(valor){
      if (valor.erro) {
        alert('Cep não encontrado');
        return;
      };
      document.getElementById('address_1').value=valor.logradouro;
      document.getElementById('address_2').value=valor.bairro;
      document.getElementById('city').value=valor.localidade;
      document.getElementById('uf').value=valor.uf;

    }

$(document).ready(function() {

	$('.colorbox').colorbox({
		width: 640,
		height: 480
	});

    $('#telephone').mask('(99) 999-999-999');

    $('#tax_id').mask('999.999.999-99', {reverse: true});

    var options =  { onComplete: function(postcode) {
          postcode_call(postcode);
    }}
    
    $('#postcode').mask('99999-999', options);

});
